package com.boot.shiro.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.boot.shiro.entity.Role;
@Mapper
public interface RoleDao extends JpaRepository<Role, String> {
	//hibernate
	Role findByRoleName(String roleName);

	@Query("from Role u where u.roleName=:roleName")
	Role findRole(@Param("roleName") String roleName);

	
	
	
	
//	
//	//mybatis
//	@Results({ //2
//		@Result(property = "id", column = "telephone"), //2
//		@Result(property = "username", column = "username"),
//		@Result(property = "telephone", column = "telephone")
//	})
//	@Select("SELECT * FROM sys_role WHERE telephone = #{phone}") //3
//	List<Role> get(String phone);
//
//	@Insert("INSERT INTO sys_role(username, telephone) VALUES (#{username}, #{telephone})") //3
//	void insert(Role user);
	@Select("SELECT role_name FROM sys_role WHERE id = #{roleId}") //3
	String getRoleById(String roleId);
	
}
